package main;
/*
 * A window that provides a player information about their character, such as statistics, weapon, and spell information.
 */
import java.awt.Component;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.Font;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;

import javax.imageio.ImageIO;
import javax.swing.*;

import jobs.Aeroclept;
import jobs.Aquamancer;
import jobs.Gaian;
import jobs.Job;
import jobs.Paladin;
import jobs.Reaper;
import jobs.Vulcan;
import spells.*;
import creatures.Wolf;

public class PlayerInfo extends JFrame implements ActionListener {
	//player that we are making this off of
	Player player;
	
	//stuff for player name
	JLabel name;
	JLabel nameLabel;
	
	//stuff for health and mana
	JLabel health;
	JLabel healthLabel;
	JLabel mana;
	JLabel manaLabel;
	JLabel levelLabel;
	JLabel level;
	
	//stuff for stats
	JLabel strLabel;
	JLabel str;
	JLabel intLabel;
	JLabel intel;
	JLabel stamLabel;
	JLabel stam;
	JLabel spLabel;
	JLabel sp;
	
	//stuff for weapon
	JLabel weaponLabel;
	JLabel dummyLabel;//used for a dummy
	JLabel damageLabel;
	JLabel damage;
	JLabel speed;
	JLabel speedLabel;
	JLabel rangeLabel;
	JLabel range;
	
	//stuff for spells
	JLabel spell1Label;
	JLabel spell1Name;
	JLabel spell1Description;
	JButton spell1Button;
	JLabel spell2Label;
	JLabel spell2Name;
	JLabel spell2Description;
	JButton spell2Button;
	JLabel spell3Label;
	JLabel spell3Name;
	JLabel spell3Description;
	JButton spell3Button;
	JLabel spell4Label;
	JLabel spell4Name;
	JLabel spell4Description;
	JButton spell4Button;
	JLabel spell5Label;
	JLabel spell5Name;
	JLabel spell5Description;
	JButton spell5Button;
	JLabel spell6Label;
	JLabel spell6Name;
	JLabel spell6Description;
	JButton spell6Button;
	JLabel spell7Label;
	JLabel spell7Name;
	JLabel spell7Description;
	JButton spell7Button;
	JLabel spell8Label;
	JLabel spell8Name;
	JLabel spell8Description;
	JButton spell8Button;
	JLabel spell9Label;
	JLabel spell9Name;
	JLabel spell9Description;
	JButton spell9Button;
	JLabel spell10Label;
	JLabel spell10Name;
	JLabel spell10Description;
	JButton spell10Button;
	
	//Panels for materials
	JPanel nameHealthStatPanel;
	JPanel healthPanel;
	JPanel statPanel;
	
	JPanel attackPanel;
	JPanel weaponPanel;
	JPanel spellPanel;
	
	public PlayerInfo (Player p) {
		setSize(new Dimension(500,400));
		player=p;
		setLayout(new GridLayout(1,3));
		this.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
		nameHealthStatPanel=new JPanel();
		nameHealthStatPanel.setLayout(new GridLayout(2,1));
		healthPanel=new JPanel();
		healthPanel.setLayout(new GridLayout(4,2));
		statPanel=new JPanel();
		statPanel.setLayout(new GridLayout(4,2));
		
		//set up health panel
		name=new JLabel("Name:");
		nameLabel=new JLabel(p.name);
		health=new JLabel("Health: ");
		healthLabel=new JLabel(p.curHealth+"/"+p.maxHealth);
		mana=new JLabel("Mana:");
		manaLabel=new JLabel(p.curMana+"/"+p.maxMana);
		level=new JLabel("Level:");
		levelLabel=new JLabel(Integer.toString(p.level));
		healthPanel.add(name);
		healthPanel.add(nameLabel);
		healthPanel.add(health);
		healthPanel.add(healthLabel);
		healthPanel.add(mana);
		healthPanel.add(manaLabel);
		healthPanel.add(level);
		healthPanel.add(levelLabel);
		
		//set up stat panel
		str=new JLabel("Strength:");
		strLabel=new JLabel(Integer.toString(p.strength));
		stam=new JLabel("Stamina: ");
		stamLabel=new JLabel(Integer.toString(p.stamina));
		intel=new JLabel("Intelligence:");
		intLabel=new JLabel(Integer.toString(p.intelligence));
		sp=new JLabel("Spirit:");
		spLabel=new JLabel(Integer.toString(p.spirit));
		statPanel.add(str);
		statPanel.add(strLabel);
		statPanel.add(stam);
		statPanel.add(stamLabel);
		statPanel.add(intel);
		statPanel.add(intLabel);
		statPanel.add(sp);
		statPanel.add(spLabel);
		
		//add the individual panels to the big panel
		nameHealthStatPanel.add(healthPanel);
		nameHealthStatPanel.add(statPanel);
		
		//set up the weapon panel
		weaponPanel=new JPanel();
		weaponPanel.setLayout(new GridLayout(4,2));
		weaponLabel=new JLabel("Weapon:");
		dummyLabel=new JLabel("A");
		damageLabel=new JLabel("Damage:");
		damage=new JLabel(Integer.toString(p.weapon1.damage));
		speedLabel=new JLabel("Attack Speed:");
		speed=new JLabel(Double.toString(p.weapon1.attackSpeed));
		rangeLabel=new JLabel("Range:");
		range=new JLabel(Integer.toString(p.weapon1.range));
		//add components to weapon label
		weaponPanel.add(weaponLabel);
		weaponPanel.add(dummyLabel);
		weaponPanel.add(damageLabel);
		weaponPanel.add(damage);
		weaponPanel.add(speedLabel);
		weaponPanel.add(speed);
		weaponPanel.add(rangeLabel);
		weaponPanel.add(range);
		
		//set up spell panel
		ArrayList <JButton> spellButtons = new ArrayList<JButton>();
		ArrayList <JLabel> spellLabels = new ArrayList<JLabel>();
		spellPanel=new JPanel();
		spellPanel.setLayout(new GridLayout(10,2));
		spell1Label=new JLabel("1");
		spell2Label=new JLabel("2");
		spell3Label=new JLabel("3");
		spell4Label=new JLabel("4");
		spell5Label=new JLabel("5");
		spell6Label=new JLabel("6");
		spell7Label=new JLabel("7");
		spell8Label=new JLabel("8");
		spell9Label=new JLabel("9");
		spell10Label=new JLabel("0");
		
		spell1Button = new JButton("none");
		spellButtons.add(spell1Button);
		spell2Button = new JButton("none");
		spellButtons.add(spell2Button);
		spell3Button = new JButton("none");
		spellButtons.add(spell3Button);
		spell4Button = new JButton("none");
		spellButtons.add(spell4Button);
		spell5Button = new JButton("none");
		spellButtons.add(spell5Button);
		spell6Button = new JButton("none");
		spellButtons.add(spell6Button);
		spell7Button = new JButton("none");
		spellButtons.add(spell7Button);
		spell8Button = new JButton("none");
		spellButtons.add(spell8Button);
		spell9Button = new JButton("none");
		spellButtons.add(spell9Button);
		spell10Button = new JButton("none");
		spellButtons.add(spell10Button);
		
		int numOfSpells = player.spells.size();
		for (int i=0;i<numOfSpells;i++){
			spellPanel.add(new JLabel(i+1 + ":"));
			spellButtons.get(i).setText(i+1+ " " +player.spells.get(i).getName());
			spellButtons.get(i).addActionListener(this);
			spellPanel.add(spellButtons.get(i));
		}
		
		setLayout(new BoxLayout(getContentPane(), BoxLayout.X_AXIS));
		add(nameHealthStatPanel);
		add(weaponPanel);
		if(p.spells.size()>=1){
		add(spellPanel);
		}//end if
	}//end constructor

	public void actionPerformed(ActionEvent e) {
		int spell = Integer.parseInt(((JButton)e.getSource()).getText().charAt(0) + "");
		JOptionPane.showMessageDialog(null, player.spells.get(spell-1).description);
	}//end method
}//end class